feature: Support basic Python and Go PoCs to be generated by the PoC …#144
feature: Support basic Python and Go PoCs to be generated by the PoC …#144QuinnDACollins wants to merge 5 commits intomainfrom
Conversation
Summary of ChangesHello @QuinnDACollins, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly expands the Proof-of-Concept (PoC) generation and execution capabilities by introducing support for Python and Go projects, in addition to the existing Node.js functionality. The changes update the system's prompt to inform users about the new language options and modify the backend logic to correctly identify, install dependencies for, and execute PoC scripts written in these languages. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
🤖 Hi @QuinnDACollins, I've received your request, and I'm working on it now! You can track my progress in the logs for more details. |
There was a problem hiding this comment.
Code Review
The pull request introduces support for generating and running Proof-of-Concept (PoC) scripts in Python and Go, in addition to the existing Node.js support. This enhances the tool's versatility for security analysis across different programming languages. The changes include modifications to the prompt for PoC generation to specify supported languages and updates to the runPoc function and its tests to handle Python and Go file extensions and their respective execution commands and dependency installation steps. The changes are well-implemented and tested.
There was a problem hiding this comment.
This pull request extends the Proof-of-Concept generation to support Python and Go, in addition to Node.js. The changes are well-implemented and include corresponding tests. The code is clear and follows existing patterns.
🔍 General Feedback
- The logic for handling different languages in
runPocis clear, but could be slightly improved for readability by using a switch statement. - The tests are comprehensive and cover the new functionality well.
|
|
||
| let installCmd: string | null = null; | ||
| let runCmd: string; | ||
| let runArgs: string[]; |
There was a problem hiding this comment.
| let runArgs: string[]; | |
| const ext = dependencies.path.extname(filePath); |
mcp-server/src/poc.ts
Outdated
| runCmd = 'python3'; | ||
| runArgs = [filePath]; | ||
| installCmd = 'pip3 install -r requirements.txt'; | ||
| } else if (ext === '.go') { | ||
| runCmd = 'go'; | ||
| runArgs = ['run', filePath]; | ||
| installCmd = 'go mod tidy'; | ||
| } else { | ||
| runCmd = 'node'; | ||
| runArgs = [filePath]; | ||
| installCmd = 'npm install --registry=https://registry.npmjs.org/'; | ||
| } | ||
| const { stdout, stderr } = await dependencies.execFileAsync('node', [filePath]); | ||
|
|
There was a problem hiding this comment.
| runCmd = 'python3'; | |
| runArgs = [filePath]; | |
| installCmd = 'pip3 install -r requirements.txt'; | |
| } else if (ext === '.go') { | |
| runCmd = 'go'; | |
| runArgs = ['run', filePath]; | |
| installCmd = 'go mod tidy'; | |
| } else { | |
| runCmd = 'node'; | |
| runArgs = [filePath]; | |
| installCmd = 'npm install --registry=https://registry.npmjs.org/'; | |
| } | |
| const { stdout, stderr } = await dependencies.execFileAsync('node', [filePath]); | |
| let installCmd: string | null = null; | |
| let runCmd: string; | |
| let runArgs: string[]; | |
| switch (ext) { | |
| case '.py': | |
| runCmd = 'python3'; | |
| runArgs = [filePath]; | |
| installCmd = 'pip3 install -r requirements.txt'; | |
| break; | |
| case '.go': | |
| runCmd = 'go'; | |
| runArgs = ['run', filePath]; | |
| installCmd = 'go mod tidy'; | |
| break; | |
| default: | |
| runCmd = 'node'; | |
| runArgs = [filePath]; | |
| installCmd = 'npm install --registry=https://registry.npmjs.org/'; | |
| } |
mcp-server/src/poc.test.ts
Outdated
| expect(mockExecAsync).toHaveBeenCalledWith('npm install --registry=https://registry.npmjs.org/', { cwd: POC_DIR }); | ||
| expect(mockExecFileAsync).toHaveBeenCalledTimes(1); | ||
| expect(mockExecFileAsync).toHaveBeenCalledWith('node', [`${POC_DIR}/test.js`]); | ||
| expect((result.content[0] as any).text).toBe( | ||
| JSON.stringify({ stdout: 'output', stderr: '' }) | ||
| expect((result.content[0] as any).text).toBe(JSON.stringify({ stdout: 'output', stderr: '' })); | ||
| }); | ||
|
|
||
| it('should execute a Python file', async () => { | ||
| const mockExecAsync = vi.fn(async () => { return { stdout: '', stderr: '' }; }); | ||
| const mockExecFileAsync = vi.fn(async () => { return { stdout: 'output', stderr: '' }; }); | ||
|
|
||
| const result = await runPoc( | ||
| { filePath: `${POC_DIR}/test.py` }, | ||
| { fs: {} as any, path: mockPath as any, execAsync: mockExecAsync as any, execFileAsync: mockExecFileAsync as any } | ||
| ); | ||
|
|
||
| expect(mockExecAsync).toHaveBeenCalledTimes(1); | ||
| expect(mockExecAsync).toHaveBeenCalledWith('pip3 install -r requirements.txt', { cwd: POC_DIR }); | ||
| expect(mockExecFileAsync).toHaveBeenCalledTimes(1); | ||
| expect(mockExecFileAsync).toHaveBeenCalledWith('python3', [`${POC_DIR}/test.py`]); | ||
| expect((result.content[0] as any).text).toBe(JSON.stringify({ stdout: 'output', stderr: '' })); | ||
| }); | ||
|
|
||
| it('should execute a Go file', async () => { | ||
| const mockExecAsync = vi.fn(async () => { return { stdout: '', stderr: '' }; }); | ||
| const mockExecFileAsync = vi.fn(async () => { return { stdout: 'output', stderr: '' }; }); | ||
|
|
||
| const result = await runPoc( | ||
| { filePath: `${POC_DIR}/test.go` }, | ||
| { fs: {} as any, path: mockPath as any, execAsync: mockExecAsync as any, execFileAsync: mockExecFileAsync as any } | ||
| ); | ||
|
|
||
| expect(mockExecAsync).toHaveBeenCalledTimes(1); | ||
| expect(mockExecAsync).toHaveBeenCalledWith('go mod tidy', { cwd: POC_DIR }); |
There was a problem hiding this comment.
There was a problem hiding this comment.
📋 Security Analysis Summary
This pull request adds support for generating Proof-of-Concept (PoC) scripts for Python and Go projects, in addition to the existing support for Node.js. The changes also include refactoring of the PoC execution logic to handle different languages.
🔍 General Feedback
- The code is well-structured and the changes are easy to follow.
- The use of
execFileinstead ofexecfor running the PoC scripts is a good security practice. - The addition of tests for the new functionality is appreciated.
- The prompt injection vulnerabilities identified in this review should be addressed before merging.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
No description provided.